<script setup>
import {  useRouter  } from 'vue-router';
import { useTokenStore, useBankInfoStore} from '../stores/token';
import { onMounted,ref } from 'vue';
import {useIMStore} from '@/stores/page_tb.js'
import {userLoginOutService} from '../api/user';

console.log(useTokenStore().token);
const imstore=useIMStore()
const router=useRouter()
const bankImg=ref('')
let bankName=ref('')


const getBankName=()=>{
    bankName.value=useBankInfoStore().bankInfo
    console.log(bankName);
}   
const goToIntelligentMatch=()=>{
    
    console.log(router);

    
    imstore.setflag(1)

    router.push('/home/imtable')
    console.log("----");
    
}

const goToRongziyulan=()=>{
    imstore.setflag(2)
    router.push('/home/rongziyulan')
}

const logout=async()=>{
    userLoginOutService()
    router.push('/login')
}

onMounted(()=>{
    
    
    goToIntelligentMatch()
    getBankName()
    bankImg.value="/src/assets/img/bank"+useBankInfoStore().bankId+".jpg"
})
    

</script>
<template>
    <div class="layout">
        <Layout class="layout_1">
            <Header>
                <Menu mode="horizontal" theme="dark" active-name="0">
                    <div class="layout-logo">融资管理系统</div>
                    <div class="layout-nav">
                        <MenuItem  >
                           <img :src="bankImg" class="bankImg">
                        </MenuItem>
                        <MenuItem name="1" class="" >
                            {{bankName}}
                        </MenuItem>
                        <MenuItem name="2" @click="logout" >
                            退出
                        </MenuItem>
                    </div>
                </Menu>
            </Header>
            <Layout class="layout-contain">
                <Sider hide-trigger :style="{background: '#fff'}" >
                    <Menu active-name="1" theme="light" width="auto">
                        <MenuItem name="1" @click="goToIntelligentMatch">智能匹配</MenuItem>

                        <MenuItem name="2" @click="goToRongziyulan">融资预览</MenuItem>
                        
                       
                    </Menu>
                </Sider>
                <Layout :style="{padding: '0 24px 24px'}">
                    <Content :style="{padding: '24px', minHeight: '280px', background: '#fff'}">
                        <RouterView/>
                    </Content>
                </Layout>
            </Layout>
        </Layout>
    </div>
</template>
<script>
    export default {
        
    }
</script>
<style scoped>
.layout{
    border: 1px solid #d7dde4;
    background: #f5f7f9;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    width: 100%; /* 设置宽度为100% */
   height: 100%; /* 设置高度为100% */
   min-height: 100vh; /* 设置最小高度为视口高度 */
}
.layout_1{
    height: 100vh;
    width: 100%;
}
.layout-contain{
    height: 100%;
    width: 100%;
}
.layout-logo{
    width: 100px;
    height: 30px;
    /* background: #5b6270; */
    border-radius: 3px;
    float: left;
    position: relative;
    color: #fff;
    top: 5px;
    left: 20px;
}
.layout-nav{
    width: 420px;
    margin: 0 auto;
    margin-right: -100px;
}
.bankImg{
    width: 30px;
    height: 30px;
    margin-top: 14px;
   
}
</style>